#include "mylabel.h"

#include <QDebug>
#include <QWheelEvent>

MyLabel::MyLabel(QWidget *parent) : QLabel(parent)
{
    this->setNum(this->index);
}


void MyLabel::wheelEvent(QWheelEvent *event)
{
     if(event->angleDelta().ry() == 120)
     {
         this->index+=this->step;
         if(this->index > this->max)
         {
             this->index = this->max;
         }
     }
     else
     {
         this->index-=this->step;
         if(this->index < this->min)
         {
             this->index = this->min;
         }
     }
     this->setNum(this->index);
}

void MyLabel::setMinNum(int n)
{
    this->min = n;
}

void MyLabel::setMaxNum(int n)
{
    this->max = n;
}

void MyLabel::setStepNum(int n)
{
    this->step = n;
}

int MyLabel::getIndex()
{
    return this->index;
}
